#pragma once

#include "GalconTypes.h"
#include <boost/enable_shared_from_this.hpp>
class QPen;
class QPixmap;
class Player;

class Planet : public QGraphicsObject, public boost::enable_shared_from_this<Planet>
{
   Q_OBJECT;
public:
   Planet(PlanetID planetID, double xCoord, double yCoord, GameColors planetColor = GameColors(0), 
          GamePlanets planetNumber = GamePlanets(0), unsigned int countOfShips = 0, 
          PlanetSize planetSize = mediumPlanet, PlayerPtr player = PlayerPtr(),   QGraphicsItem *parent = 0);
   ~Planet();
   void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget /* = 0 */);
   virtual QPainterPath shape() const;
   virtual QRectF boundingRect() const;
   unsigned int CountOfShips() const { return static_cast<unsigned>(m_countOfShips); }
   void CountOfShips(unsigned int val) { m_countOfShips = val; }
   PlanetID GetPlanetID() const {return m_planetID; }
   double GetXCoord() const { return m_xCoord; }
   double GetYCoord() const { return m_yCoord; }
   PlayerPtr PlanetOwner() const { return m_planetOwner; }
   void PlanetOwner(PlayerPtr val) { m_planetOwner = val; }
   PlayerID GetPlanetOwnerID() const;
protected:
   virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
   virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
   virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
   virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

public slots:
   void increaseCountOfShips();

signals:
   void hover(Planet*);
   void itemMouseRelease(PlanetPtr);

private:
   void init();
   void disconnectSignals();
   boost::shared_ptr<QFont> m_font;
   PlayerPtr m_planetOwner;
   const PlanetID m_planetID;
   const PlanetSize m_planetSize;
   qreal m_countOfShips;
   const double m_xCoord;
   const double m_yCoord;
   QPen m_borderPen;
   QPixmap m_pixmap;
   bool m_pressed;
};
